/*
 * Copyright © 2022 XXXXXXXXX
 * @Author: zhangxiang
 * @Date: 2022-06-06 15:03:23
 * @LastEditors: zhangxiang
 * @LastEditTime: 2022-09-27 09:54:25
 * @Description:
 *
 */

import request from '@/utils/request'
import request2 from '@/utils/request2'
import { POST } from '@/utils/request'
import { downLoadFile } from '@/utils/request2'

/**
 * @description:
 * @param {*} data
 * @return {*}
 */
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

/**
 * @description: 退出登录
 * @return {*}
 */
export function logout() {
  return request2({
    url: '/logout',
    method: 'get'
  })
}

/**
 * @description: 获取用户信息
 * @param {*} params
 * @return {*}
 */
export function getUserInfo(params) {
  return request({
    url: '/user/auth',
    method: 'get',
    params
  })
}

/**
 * @description: 用户注册
 * @param {*} params
 * @return {*}
 */
export function registUser(params) {
  return POST('/user', params)
}

/**
 * @description: 用户列表
 * @param {*} params
 * @return {*}
 */
export function getUserList(params) {
  return POST('/user/list', params)
}

/**
 * @description: 获取所有用户名
 * @param {*} params
 * @return {*}
 */
export function getAllUser(params) {
  return POST('/user/names', params)
}

/**
 * @description: 审核用户
 * @param {*} params
 * @return {*}
 */
export function audit(params) {
  return POST('/user/audit', params)
}

/**
 * @description: 编辑用户
 * @param {*} params
 * @return {*}
 */
export function userUpdate(params) {
  return POST('/user/update', params)
}

/**
 * @description: 用户删除
 * @param {*} params
 * @return {*}
 */
export function userDelete(params) {
  return POST('/user/delete', params)
}

/**
 * @description: 用户下载
 * @param {*} params
 * @return {*}
 */
export function tempExport(params) {
  return downLoadFile('/user/template/export', params)
}

/**
 * @description: 用户模板导入
 * @param {*} params
 * @return {*}
 */
export function tempUpload(params) {
  return POST('/user/template/import', params)
}

/**
 * @description: 角色列表
 * @param {*} params
 * @return {*}
 */
export function getRoleList(params) {
  return POST('/role/roleList', params)
}

/**
 * @description: 所有角色
 * @param {*} params
 * @return {*}
 */
export function getAllRole(params) {
  return POST('/role/getAllRoles', params)
}

/**
 * @description: 角色详情
 * @param {*} params
 * @return {*}
 */
export function roleDetail(params) {
  return POST('/role/roleDetailInfo', params)
}

/**
 * @description: 增加角色
 * @param {*} params
 * @return {*}
 */
export function addRole(params) {
  return POST('/role/saveRole', params)
}

/**
 * @description: 角色更新
 * @param {*} params
 * @return {*}
 */
export function updateRole(params) {
  return POST('/role/updateRoleInfo', params)
}

/**
 * @description: 角色权限更新
 * @param {*} params
 * @return {*}
 */
export function updateRoleAuth(params) {
  return POST('/role/updateRoleAuth', params)
}

/**
 * @description: 角色删除
 * @param {*} params
 * @return {*}
 */
export function deleteRole(params) {
  return POST('/role/deleteRole', params)
}

/**
 * @description: 获取单位
 * @param {*} params
 * @return {*}
 */
 export function getCompanys(params) {
  return request({
    url: '/user/companys',
    method: 'get',
    params
  })
}

/**
 * @description: 日志查询
 * @param {*} params
 * @return {*}
 */
export function logInfo(params) {
  return POST('/log/list', params)
}
